/*
 *   Copyright (c) 2010-2022, SIUFUNG
 */
package net.siufung.market.base.dict.controller.model.dict;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import net.siufung.core.model.AbstractDto;
import net.siufung.core.model.enums.DefaultEnum;
import net.siufung.core.utils.CopyUtil;
import net.siufung.market.base.dict.mapper.entity.Dict;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 字典数据 新增数据传参对象
 * </p>
 * @author 陈建峰
 * @since 2022-07-08 15:30:15
 */
@Slf4j
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="DictSaveDto", description="字典数据新增数据传参对象")
public class DictSaveDto extends AbstractDto {

    private static final long serialVersionUID = -2273752008081776995L;

    /**
     * 字典编码
     */
    @ApiModelProperty(value = "字典编码")
    private String dictCode;

    /**
     * 字典值
     */
    @ApiModelProperty(value = "字典值")
    @NotBlank(message = "字典值不能为空!")
    @Length(max=64, message="字典值长度不大于64!")
    private String dictValue;

    /**
     * 类型
     */
    @ApiModelProperty(value = "类型Id")
    @NotNull(message = "字典类型不能为空！")
    private Integer dictTypeId;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Length(max=64, message="备注长度不大于64!")
    private String description;

    /**
     * Dict 转化成 DictSaveDto 数据领域实体
     * @return Dict
     */
    public Dict to(){
        Dict dict = new Dict();
        CopyUtil.copyProperties(this, dict);
        dict.setDefaultFlag(DefaultEnum.NOT.getValue());
        return dict;
    }
}